#include "Reactor/TcpServer.h"


TcpServer::TcpServer(const string & ip,unsigned short port)
:_acceptor(ip,port)
,_loop(_acceptor)
{

}
TcpServer::~TcpServer()
{

}
void TcpServer::start()
{
    _acceptor.ready();
    _loop.loop();
}
void TcpServer::stop()
{
    LogDebug("执行_loop.unloop()");
    _loop.unloop();
}
void TcpServer::setAllCallback(TcpConnectionCallback &&onConnection,
    TcpConnectionCallback &&onMessage, 
    TcpConnectionCallback &&onClose)
 {
    _loop.setNewConnectionCallback(std::move(onConnection));//连接建立
    _loop.setMessageCallback(std::move(onMessage));//消息到达
    _loop.setCloseCallback(std::move(onClose));//连接断开
 }